package com.ruoyi.web.controller.eamp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.constant.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.eamp.domain.EampMeetingPeople;
import com.ruoyi.eamp.service.IEampMeetingPeopleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会议人员Controller
 * 
 * @author ruoyi
 * @date 2024-08-09
 */
@RestController
@RequestMapping("/eamp/people")
public class EampMeetingPeopleController extends BaseController
{
    @Autowired
    private IEampMeetingPeopleService eampMeetingPeopleService;

    /**
     * 查询会议人员列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:people:list')")
    @GetMapping("/list")
    public TableDataInfo list(EampMeetingPeople eampMeetingPeople)
    {
        startPage();
        List<EampMeetingPeople> list = eampMeetingPeopleService.selectEampMeetingPeopleList(eampMeetingPeople);
        return getDataTable(list);
    }

    /**
     * 导出会议人员列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:people:export')")
    @Log(title = "会议人员", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EampMeetingPeople eampMeetingPeople)
    {
        List<EampMeetingPeople> list = eampMeetingPeopleService.selectEampMeetingPeopleList(eampMeetingPeople);
        ExcelUtil<EampMeetingPeople> util = new ExcelUtil<EampMeetingPeople>(EampMeetingPeople.class);
        util.exportExcel(response, list, "会议人员数据");
    }

    /**
     * 获取会议人员详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:people:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eampMeetingPeopleService.selectEampMeetingPeopleById(id));
    }

    /**
     * 新增会议人员
     */
    @PreAuthorize("@ss.hasPermi('eamp:people:add')")
    @Log(title = "会议人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EampMeetingPeople eampMeetingPeople)
    {
        return toAjax(eampMeetingPeopleService.insertEampMeetingPeople(eampMeetingPeople));
    }

    /**
     * 修改会议人员
     */
    @PreAuthorize("@ss.hasPermi('eamp:people:edit')")
    @Log(title = "会议人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EampMeetingPeople eampMeetingPeople)
    {
        return toAjax(eampMeetingPeopleService.updateEampMeetingPeople(eampMeetingPeople));
    }

    /**
     * 删除会议人员
     */
    @PreAuthorize("@ss.hasPermi('eamp:people:remove')")
    @Log(title = "会议人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eampMeetingPeopleService.deleteEampMeetingPeopleByIds(ids));
    }

    @PostMapping("/attendees")
    public TableDataInfo getattendeesList(){
        List<EampMeetingPeople> list1 =eampMeetingPeopleService.getattendeesList(0);
        List<EampMeetingPeople> list2 =eampMeetingPeopleService.getattendeesList(1);
        List<EampMeetingPeople> list3 =eampMeetingPeopleService.getattendeesList(2);
        TableDataInfo result = new TableDataInfo();
        result.setCode(HttpStatus.SUCCESS);
        result.setMsg("查询成功");
        result.setRows(list1);
        result.setRows(list2);
        result.setRows(list3);
        return result;
    }
}
